<?php
require_once 'mysql.php';

$docs = file_get_contents('php://input');
$docs = json_decode($docs, true);
$table = $docs['table'];
$data = $docs['data'];

// var_dump($table);
// print_r($data);
// 配置连接参数
$config = [
    'host' => 'localhost',
    'username' => 'username',
    'password' => 'password',
    'dbname' => 'projectDB'
];

// 连接数据库
$mysql = new mysql();

$mysql->connect($config);

// $table = 'childrenclass';
// $data = [
//     'name' => '机器狗',
//     'father_id' => 4,
//     'level' => 1
// ];

$result = $mysql->insert($table, $data);

echo $result;
// print_r($mysql->fetchAll());